﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace DataPreperation
{
    class DocumentsReader
    {
        /// <summary>
        /// read all files
        /// </summary>
        /// <returns></returns>
        public static Dictionary<string, string> ReadAllFile()
        {
            Dictionary<string, string> m_allDocs = new Dictionary<string, string>();
            string path = Directory.GetCurrentDirectory(); // get the directory where the EXE/Application file is
            path += "\\Files"; // add the folder name "Files" to the path
            string[] files = Directory.GetFiles(path); // get all files from the path

            foreach (string file in files) // for each of the files
            {
                string temp;
                List<string> cleanLine = new List<string>();
                string fileName = file.Split('\\').Last();
                StreamReader sr = new StreamReader(file); // open a new StreamReader
                if (fileName == "stopWords.txt")//if file: "stopWords.txt"
                    continue;
                temp = sr.ReadToEnd();
                m_allDocs.Add(fileName, temp); //adds all text from the file with key = Doc Name
                sr.Close();
            }
            return m_allDocs;
        }
    }
}
